<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    //1、给函数的参数设置默认值
    function add(a, b=1) {
        return a + b
    }
    console.log(add(20))

    //2、不定参数
    function f(...values) {
        console.log(values.length)
    }
    f(2,3)
    f(2,3,4)

    //3、箭头函数
    //es6之前写法
    // var print = function(object) {
    //     console.log(object)
    // }
    var print = obj => console.log(obj)
    print("1")

    //4、箭头函数+解构表达式
    const person = {
        name: "jack",
        age: 18,
        language: ['js','css']
    }
    // var print = (param) => console.log("hi:"+param.name)
    // print(person)
    var print = ({name}) => console.log("hi:"+name)
    print(person)

</script>
</body>
</html>